//
//  SDAlertActionModel.m
//  SDAlertView
//
//  Created by sander on 2017/10/24.
//

#import "SDAlertActionModel.h"

#import "SDAlertViewController.h"

@implementation SDAlertActionModel

- (instancetype)initWithTitle:(NSAttributedString * )title andActionBlock:(SDActionButtonBlock)block
{
    self = [super init];
    if (self) {
        _alert_string = title;
        _actionBlock = block;

    }
    return self;
}

- (SDAlertViewController * )alert_viewController
{
    return (SDAlertViewController * )self.targetController;
}

- (void)dismissViewController
{
    __weak typeof(self) weak_self = self;
    [[self alert_viewController] dismissAlert:^{
        if (weak_self.actionBlock) {
            weak_self.actionBlock(weak_self);
        }
    }];
}

@end
